package com.xhx.dao.mongodb;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Date;

/**
 * 地理坐标 实体模型类
 */
@Document(collection = "GisCoordinate") // 被映射为对应的集合名字
@CompoundIndexes({
        //@CompoundIndex(name = "gisUser_gisTime", def = "{'gisTime':-1,'gisUser':1}")
//        @CompoundIndex(name = "gisUser", def = "{'gisUser':1}")
}) // 建立 复合索引，提高查询速度，1为正序，-1为倒序
public class GisCoordinate implements Serializable {

    //#region [ 成员变量 ]

    /**
     * 流水编号
     */
    @Id // Mongo主键
    @MongoDBAutoKey // 自定义项
    @JSONField(ordinal = 1, name = "GisId")
    @JsonProperty("GisId")
    @Field(value = "_id") // Mongo 键名
//    @Indexed(unique = true) // Mongo 唯一索引
    private Integer gisId = 0; //
    // private long gisId;   // 小写long

    /**
     * 涉及账户
     */
    @JSONField(ordinal = 2, name = "GisUser")
    @JsonProperty("GisUser")
//    @Indexed // Mongo 普通索引
//    @Transient // 不入库
    private Integer gisUser = 0; // 0

    /**
     * 坐标系
     */
    @JSONField(ordinal = 3, name = "GisType")
    @JsonProperty("GisType")
    private String gisType; //

    /**
     * 经度
     */
    @JSONField(ordinal = 4, name = "GisLongitude")
    @JsonProperty("GisLongitude")
    private String gisLongitude; //

    /**
     * 纬度
     */
    @JSONField(ordinal = 5, name = "GisLatitude")
    @JsonProperty("GisLatitude")
    private String gisLatitude; //

    /**
     * 时间
     */
    @JSONField(ordinal = 6, name = "GisTime")
    @JsonProperty("GisTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date gisTime = new Date();

    @CreatedDate
    @Transient // 不入库
    private Long createdAt;

    @LastModifiedDate
    @Transient // 不入库
    private Long updatedAt;

    //#endregion

    //#region [ getter/setter ]

    public Integer getGisId() {
        return gisId;
    }

    public void setGisId(Integer gisId) {
        this.gisId = gisId;
    }

    public Integer getGisUser() {
        return gisUser;
    }

    public void setGisUser(Integer gisUser) {
        this.gisUser = gisUser;
    }

    public String getGisType() {
        return gisType;
    }

    public void setGisType(String gisType) {
        this.gisType = gisType;
    }

    public String getGisLongitude() {
        return gisLongitude;
    }

    public void setGisLongitude(String gisLongitude) {
        this.gisLongitude = gisLongitude;
    }

    public String getGisLatitude() {
        return gisLatitude;
    }

    public void setGisLatitude(String gisLatitude) {
        this.gisLatitude = gisLatitude;
    }

    public Date getGisTime() {
        return gisTime;
    }

    public void setGisTime(Date gisTime) {
        this.gisTime = gisTime;
    }

    public Long getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Long createdAt) {
        this.createdAt = createdAt;
    }

    public Long getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Long updatedAt) {
        this.updatedAt = updatedAt;
    }

    //#endregion
}
